/*
 * Copyright (c) zhg2yqq.com Corp.
 * All Rights Reserved.
 */
package com.zhg2yqq.wheels.security.context;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import com.zhg2yqq.wheels.security.ISecurityRepository;

/**
 * 登出删除缓存
 *
 * @author zhg2yqq, 2023年2月15日
 * @version zhg2yqq v1.0
 */
public class CustomLogoutHandler implements LogoutHandler {
    private final ISecurityRepository securityRepository;

    public CustomLogoutHandler(ISecurityRepository securityRepository) {
        this.securityRepository = securityRepository;
    }

    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response,
                       Authentication authentication) {
        securityRepository.clearLoginUser(request);
    }
}
